{% extends 'admin/base/base.html' %}


{% block title %}
  用户组添加页
{% endblock %}

{% block content_header %}
  用户组添加
{% endblock %}

{% block header_option_desc %}
  用户组添加
{% endblock %}


{% block content %}
  <div class="row">
    <div class="col-md-12 col-xs-12 col-sm-12">
      <div class="box box-primary">
        <div class="box-body">

          <div class="form-group" style="margin-top: 30px;">
            <label for="news-title">组名(80个字以内)</label>
            {% if group %}
              <input type="text" class="form-control" id="news-title" name="news-title" placeholder="请输入用户组名"
                     value="{{ group.name }}">
            {% else %}
              <input type="text" class="form-control" id="news-title" name="news-title" placeholder="请输入用户组名"
                     autofocus>
            {% endif %}
          </div>

          <div class="form-group" style="margin-top: 20px">
            <label for="group-permissions">权限(按住 ”Control“，或者Mac上的 “Command”，可以选择多个。)</label>
            <select multiple class="form-control" name="group-permissions" id="group-permissions"
                    style="height: 450px; margin-top: 20px">
              {% for one_permission in permissions %}
                {% if group and one_permission in group.permissions.all %}
                  <option value="{{ one_permission.id }}" title="{{ one_permission }}" selected>
                    {{ one_permission }}</option>
                {% else %}
                  <option value="{{ one_permission.id }}"
                          title="{{ one_permission }}">{{ one_permission }}</option>
                {% endif %}
              {% endfor %}
            </select>
          </div>


        </div>
        <div class="box-footer">
          {% if group %}
            <a href="javascript:void (0);" class="btn btn-primary pull-right" id="btn-pub-news"
               data-news-id="{{ group.id }}">更新用户组 </a>
          {% else %}
            <a href="javascript:void (0);" class="btn btn-primary pull-right" id="btn-pub-news">创建用户组 </a>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
{% endblock %}

{% block script %}
  <script src="{% static 'js/admin/user/groups_add.js' %}"></script>
{% endblock %}